In typical data processing systems, a compiler reads source code and creates the object code which is ultimately processed. Typically, the compiler creates a data structure which will support property values which are defined later in the source code or during run time. In an object oriented system, the compiler may create a class and a mechanism for creating instances of that class with defined fields of preallocated memory space into which the values are stored.
An alternative data structure which has, for example, been supported in the language allows values to be stored in strings or arrays as options associated with an instance object.
In a data processing system according to one aspect of the invention, a class supports values in instances of the class. A nonlocal value hierarchy, such as a graphical hierarchy, is defined separate from the class hierarchy. In an instance of the class, a nonlocal value is set and that nonlocal value applies to the instance of the class and to other objects in the nonlocal value hierarchy.
In another aspect of the invention, an object has an option data structure which supports references to nonlocal option values without preallocation of memory space for the full option values. A nonlocal option hierarchy of objects, such as a graphical hierarchy, is defined. When a nonlocal option value is set in the option data structure, the set nonlocal option value applies to other objects in the nonlocal option hierarchy.
Values may be stored in instances of the class in defined fields of preallocated memory space and in an option data structure which supports references to the nonlocal values without preallocation of memory space for the nonlocal values. The option data structure may support both nonlocal values which apply to other objects in the nonlocal value hierarchy and local values which apply only to the object in which they are set. The option data structure may comprise a linked list of option items having option values in an instance of the class.
All objects to which a nonlocal value applies may be notified of any change in a value that affects them. Only a changed object and descendants of the changed object in the nonlocal value hierarchy need be notified of the change.
With a declaration of a nonlocal value in a class object, a corresponding nonlocal data structure may be created in a designated common superclass to support setting of a nonlocal value on an object whose superclasses do not contain an explicit declaration of the nonlocal value. The common superclass may be an immediate subclass of a class that provides a concrete implementation of a nonlocal value processing method.
Objects that are to be notified when a nonlocal value changes may be registered. Registered nonlocal values may be saved to reduce computation of a set of nonlocal values for which an object registers. An object may be notified when a descendant in the nonlocal value hierarchy changes the set of nonlocal values for which it is registered.
An nonlocal value binding declared in a second software package may attach to a class defined in a first software package. The nonlocal value binding declared in the second software package may be compiled to a second nonlocal value data structure separate from a first nonlocal value data structure of the first software package. The second nonlocal value data structure may comprise a hash table which holds links to the option binding declared in the second software package. The nonlocal value binding may be located by examining the first nonlocal value data structure and the second nonlocal value data structure.
The nonlocal data structure may include a default value. In a get operation to an instance of the class, if a nonlocal value which applies to the instance has been set, the set nonlocal value may be obtained. If no value which applies has been set, the default value for the class is obtained.